/* 组织类型api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL = env.VITE_API_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL = 'http://192.168.31.129:39001';
// const baseURL = 'http://192.168.31.129:39001';
// const baseURL = 'http://192.168.31.129:39001';
// const baseURL = 'http://192.168.31.129:39001';

// 查询组织类型列表
export function OrganizationPatternSearch(params: any) {
  return ajaxService({
    url: '/hr/organization/pattern',
    // url: '/organization/set/pattern/search',
    method: 'get',
    params,
    baseURL,
    isLoading: true
  });
}

// 查重组织类型名称
export function CheckOrganizationType(params: any) {
  return ajaxService({
    url: '/hr/organization/pattern/repeat',
    // url: '/organization/pattern/repeat',
    method: 'get',
    params,
    baseURL
  });
}

// 修改表数据
export interface amend {
  name: string; // 组织类型
  isLegalPerson: number; // 是否是法人
  status: any; // 是否启用
  description?: string; // 描述
  id: number;
}

// 修改组织类型数据
export function OrganizationPatternAmend(data: amend) {
  return ajaxService({
    url: '/hr/organization/pattern',
    // url: '/organization/set/pattern',
    data,
    method: 'PUT',
    baseURL
  });
}

// 新增表数据
export function OrganizationPatternNewly(data: any) {
  return ajaxService({
    url: '/hr/organization/pattern',
    // url: '/organization/set/pattern',
    method: 'post',
    noToken: false,
    data,
    baseURL,
    isLoading: true
  });
}
// 删除
export interface OrganizationPatternDelete {
  ids: [];
}

// 删除组织类型
export function OrganizationPatternDelete(data: OrganizationPatternDelete) {
  return ajaxService(
    {
      url: '/hr/organization/pattern',
      // url: '/organization/set/pattern',
      method: 'delete',
      data,
      baseURL
    },
    {
      mode: 'success',
      message: '删除成功'
    }
  );
}

/**
 * 部门信息模板api
 */

export interface GetDepartmentTemplate {
  id: number;
  page: number;
  size: number;
}
// export function GetDepartmentTemplate(params: GetDepartmentTemplate) {
//   return ajaxService({
//     url: '/organization/set/pattern/template',
//     method: 'get',
//     noToken: false,
//     params,
//     baseURL
//   });
// }

// 获取模板列表
export function GetDepartmentTemplate(params: any) {
  return ajaxService({
    url: '/hr/organization/template',
    // url: '/organization/template/set',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

// 组织模板名称查重
export function CheckDepartmentTemplate(params: any) {
  return ajaxService({
    url: '/hr/organization/template/repeat',
    // url: '/organization/template/repeat',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

// 获取模板详情
export function GetDepartmentTemplateDetail(params: any) {
  return ajaxService({
    url: '/hr/organization/template/detail',
    // url: '/organization/template/detail',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

// 删除模板列表
export function DelOrganizaitonTemplate(data: any) {
  return ajaxService({
    url: '/hr/organization/template',
    method: 'delete',
    baseURL: baseURL,
    data
  });
}

// 新增组织模板
export function PostOrganizaitonTemplate(data: any) {
  return ajaxService({
    url: '/hr/organization/template',
    // url: '/organization/organization/template',
    method: 'post',
    baseURL: baseURL,
    data
  });
}

// 编辑组织模板
export function PutOrganizaitonTemplate(data: any) {
  return ajaxService({
    url: '/hr/organization/template',
    // url: '/organization/organization/template',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 编辑组织第一层模板
export function PutOrganizationTemplate(data: any) {
  return ajaxService({
    url: '/template/set',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 合并母模板到子模板
export function PutMergeTemplate(data: any) {
  return ajaxService({
    url: '/template/organization/merge/set',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 修改组织默认状态模板
export function PutOrganizationTemplateState(data: any) {
  return ajaxService({
    url: '/hr/organization/pattern/template/default',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

// 删除模板子集
export function DelOrganizationTemplateCollections(data: any) {
  return ajaxService({
    url: '/hr/organization/template/collection',
    method: 'delete',
    baseURL: baseURL,
    data
  });
}

// 删除模板子集里面的控件
export function DelOrganizationTemplateControls(data: any) {
  return ajaxService({
    url: '/hr/organization/template/control',
    method: 'delete',
    baseURL: baseURL,
    data
  });
}
